package package02;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Dateutils {
    /**
     * @param date
     * @param format
     * @Description TODO
     * @Return java.lang.String
     * @Author zzj
     * @Date 2020/7/15 13:36
     **/
    public static String dateToString(Date date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        String s = sdf.format(date);
        return s;
    }


    /**
     * @param s
     * @Description 字符串转日期
     * @Return java.util.Date
     * @Author zzj
     * @Date 2020/7/15 12:50
     **/
    public static Date stringToDate(String s, String format) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date date = sdf.parse(s);
        return date;
    }
}
